package com.sgj.gulimall.product.dao;

import com.sgj.gulimall.product.entity.SkuSaleAttrValueEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sgj.gulimall.product.vo.SkuItemVo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * sku销售属性&值
 *
 * @author guojishen
 * @email 1261550408@qq.com
 * @date 2021-06-11 14:21:46
 */
@Mapper
public interface SkuSaleAttrValueDao extends BaseMapper<SkuSaleAttrValueEntity> {

    /**
     * 获取 spu 销售属性组合
     * @param spuId
     * @return
     */
    List<SkuItemSaleAttrVo> getSaleAttrsBySpuId(@Param("spuId") Long spuId);

    /**
     * 获取销售属性
     * @param skuId
     * @return
     */
    @Select("select concat(attr_name, ':', attr_value) from pms_sku_sale_attr_value where sku_id = #{skuId}")
    List<String> getSkuSaleAttrValuesAsStringList(@Param("skuId") Long skuId);
}